package com.bbseguros.pesquisador;

public class PesquisadorException extends Exception {

	private static final long serialVersionUID = 1L;
	private int codigoErro = SYSTEM_ERROR;
	private String responseCode;
	private String errorMessage;

	public static final int SESSION_ERROR = 99;
	public static final int SCREEN_ERROR = 5;
	public static final int ISO_TIMEOUT = 4;
	public static final int SQL_ERROR = 3;
	public static final int LEGACY_ERROR = 2;
	public static final int SYSTEM_ERROR = 1;

	public PesquisadorException(String errorMessage) {
		super(errorMessage);
		this.errorMessage = errorMessage;
		this.codigoErro = SYSTEM_ERROR;
	}

	public PesquisadorException(String errorMessage, int codigoErro) {
		super(errorMessage);
		this.errorMessage = errorMessage;
		this.codigoErro = codigoErro;
	}
	
	public PesquisadorException(String errorMessage, int codigoErro, String responseCode) {
		super(errorMessage);
		this.errorMessage = errorMessage;
		this.codigoErro = codigoErro;
		this.responseCode = responseCode;
	}

	public void setCodigoErro(int codigoErro) {
		this.codigoErro = codigoErro;
	}

	public int getCodigoErro() {
		return codigoErro;
	}

	public String getErrorMessage() {
		return errorMessage;
	}

	public String getResponseCode() {
		if(responseCode == null){
			responseCode = String.valueOf(codigoErro);
		}
		
		return responseCode;
	}

	public void setResponseCode(String responseCode) {
		this.responseCode = responseCode;
	}
}